//
//  ProjectListDetailCtrl.m
//  laowu
//
//  Created by Northwan on 15/5/10.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "ProjectListDetailCtrl.h"
#import "ProjectDataTool.h"
#import "LWLoginCtrl.h"
@interface ProjectListDetailCtrl ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UILabel *jobNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *salaryLabel;
@property (weak, nonatomic) IBOutlet UILabel *companyLabel;
@property (weak, nonatomic) IBOutlet UILabel *qualityLabel;
@property (weak, nonatomic) IBOutlet UILabel *scaleLabel;
@property (weak, nonatomic) IBOutlet UILabel *publishLabel;
@property (weak, nonatomic) IBOutlet UILabel *realLabel;
@property (weak, nonatomic) IBOutlet UILabel *startLabel;
@property (weak, nonatomic) IBOutlet UILabel *projectTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *areaLabel;
@property (weak, nonatomic) IBOutlet UILabel *requireLabel;
@property (weak, nonatomic) IBOutlet UILabel *jobResponsebilityLabel;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
- (IBAction)applyJobTap:(UIButton *)sender;

@property (strong,nonatomic)ProjectlistInfoResult *result;
@end

@implementation ProjectListDetailCtrl

+(instancetype)initWithData:(ProjectlistInfoResult *)result{
    ProjectListDetailCtrl *object = [[ProjectListDetailCtrl alloc]init];
    object.result = result;
    return object;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.scrollView setAlwaysBounceVertical:YES];
    [self.navigationItem setTitle:_result.job_name];
    [_bottomView setCornerRadius:0 borderWidth:1 borderColor:RGBColor(231, 231, 231)];
    [self initData];
}

-(void)initData{
    [_jobNameLabel setText:_result.job_name];
    [_salaryLabel setText:_result.salary];
    [_companyLabel setText:_result.company_name];
    [_qualityLabel setText:_result.company_nature];
    [_scaleLabel setText:_result.size_info];
    [_publishLabel setText:_result.release_date];
    [_realLabel setText:_result.fiction];
    [_startLabel setText:_result.start_date];
    [_projectTimeLabel setText:_result.project_time];
    [_areaLabel setText:_result.address];
    [_requireLabel setText:_result.job_description];
    [_jobResponsebilityLabel setText:_result.job_duty];
}

- (IBAction)applyJobTap:(UIButton *)sender {
    NSLog(@"申请职位");
    if (!ISLOGIN) {
        LWLoginCtrl *ctrl = [[LWLoginCtrl alloc] init];
        [self presentViewController:[[CustomNavigationCtrl alloc] initWithRootViewController:ctrl] animated:YES completion:nil];
        return;
    }
    MBProgressHUD *lodingView = [DialogUtils showLoadingWithView:self.view];
    [ProjectDataTool applyJob:_result.id success:^(BaseResponse *result) {
        [lodingView hide:YES];
        if(result.isSucc){
            [DialogUtils showTipsWithView:self.view String:@"您的申请已发送成功"];
        }else{
            [DialogUtils showTipsWithView:self.view String:result.msg];
        }
    } failure:^(NSError *error) {
        [lodingView hide:YES];
        [DialogUtils showTipsWithView:self.view String:@"申请失败"];
    }];
}

@end
